//
//  MoBanThreeViewController.m
//  MoBan
//
//  Created by apple on 16/7/8.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "MoBanThreeViewController.h"
#import "ZBMoBanThree.h"
#import "MoBanThreeCell.h"
#import "ZBMoBanThreeFotterView.h"
@interface MoBanThreeViewController ()<UITableViewDataSource,UITableViewDelegate,MoBanThreeCellDeleget>
@property(nonatomic,strong)UITableView *tableview;
@property(nonatomic,strong)NSMutableArray *array;
@end

@implementation MoBanThreeViewController
-(NSMutableArray *)array
{
    if (!_array) {
        _array = [NSMutableArray array];
    }
    return _array;
}
-(UITableView *)tableview
{
    if (!_tableview) {
        _tableview = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, KscrW, KscrH-KBar1)];
        _tableview.dataSource = self;
        _tableview.delegate = self;
    }
    return _tableview;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    NSArray *array0 = @[@"1",@"2",@"3",@"4",@"5",@"6",@"4",@"5",@"6",@"4",@"5",@"6"];
    NSArray *array1 = @[@"1"];
    NSArray *array2 = @[@"1",@"2",@"3",@"4"];
    NSArray *array3 = @[@"1",@"2",@"3",@"4"];
    
    [self.array addObject:array0];
    [self.array addObject:array1];
    [self.array addObject:array2];
    [self.array addObject:array3];
    
    [self.view addSubview:self.tableview];

    
    // Do any additional setup after loading the view.
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [ZBMoBanThree ZBTableviewCellCountAtSection:section WithArray:self.array];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section<3) {
      NSString *str =  [ZBMoBanThree ZBCellIndentfireInsection:indexPath.section];
        MoBanThreeCell *cell = [tableView dequeueReusableCellWithIdentifier:str];
        if (!cell) {
            cell = [[MoBanThreeCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:str];
        }
        cell.deleget = self;
        [cell ZBdatasouce:self.array[indexPath.section]];
        return cell;

    }
    
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:FirstCell];
    }
    
    return cell;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return self.array.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return [ZBMoBanThree ZBtableviewCellHightAtSection:indexPath.section WithArray:self.array];
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{

    return [ZBMoBanThree ZBtableviewFotterViewHightAtSection:section WithArray:self.array];
}
- (nullable UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    if (section==2) {
        ZBMoBanThreeFotterView *foter = [[ZBMoBanThreeFotterView alloc]init];
        return foter;
    }
    
    return nil;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"%ld",(long)indexPath.row);
    if (indexPath.section==1) {
        [ZBProssHud showsuccessFrom:self.view with:@"点击第二个cell"];
    }
}
/**
 滑动界面的点击
 */
-(void)ZBdidSelected:(NSInteger)index;
{

    [ZBProssHud showsuccessFrom:self.view with:[NSString stringWithFormat:@"第%ld个被点击",index]];
}
-(void)ZBThreecellSelect:(NSInteger)index
{
    [ZBProssHud showsuccessFrom:self.view with:[NSString stringWithFormat:@"第%ld个被点击",index]];


}
@end
